package liumengbaio.lolzhangyoubao.Activity.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


import com.squareup.picasso.Picasso;

import java.util.List;

import liumengbaio.lolzhangyoubao.Activity.InFo.VideoEntity;
import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/8/24.
 */
public class VideoAdapter extends BaseAdapter {


    private List<VideoEntity.DataBean.CatwordIdBean> mVideoEntitys;
    private Context mContext;

    public VideoAdapter(List<VideoEntity.DataBean.CatwordIdBean> mVideoEntity, Context mContext) {
        this.mVideoEntitys = mVideoEntity;
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        return mVideoEntitys.size();
    }

    @Override
    public Object getItem(int position) {
        return mVideoEntitys.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_video_gamevideo, null);
            holder.video_iv = (ImageView) convertView.findViewById(R.id.video_item_iv);
            holder.video_tv = (TextView) convertView.findViewById(R.id.video_item_tv);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        VideoEntity.DataBean.CatwordIdBean bean = mVideoEntitys.get(position);
        holder.video_tv.setText(bean.getName());
        Picasso.with(mContext).load(bean.getPic_url()).into(holder.video_iv);
        return convertView;
    }

    public class ViewHolder {
        private ImageView video_iv;
        private TextView video_tv;
    }

}
